<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function getSum(num1 = 0, num2 = 0) {
      // console.log(num2) 形参被赋值了
      let sum = 0
      for (let i = num1; i <= num2; i++) {
        sum += i
      }
      console.log(sum);
    }
    getSum(1, 100)
    getSum(5, 7)
    getSum()

    function getSum1(x, y) {
      console.log(x + y)
    }
    getSum1() //NaN,形参不给值，默认值为undefined,于是 x + y = NaN
    function getSum2(x = 0, y = 0) {
      console.log(x + y)
    }
    getSum2()
    getSum2(2, 9)
  </script>
</body>

</html>